import 'babel-polyfill';
let a = 10;
console.log(a);
import '../scss/index';
import {poem} from 'poem';

// let arr = [];

// function fun(i){
//     return new Promise((resolve,reject) =>{
//         arr.push(i);
//         resolve(true);
//     })
// }

// async function add(){
//     for(let i =0;i<10;i++){
//        await fun(i);
//     } 
// }

// add();
// console.log(arr);

// [1,2,3,4,5,6,7,8,9]

import BScroll from 'better-scroll'

class Ani{
    constructor(options){
        this.data = options.data;
        this.con = document.querySelector('.con');
        this.scroll = new BScroll('.wrap');
        this.init();
        console.log(this.scroll);
    }

    async init(){
        for(let i = 0;i<this.data.length;i++){
            await this.createElement(i)
        }
    }
    createElement(i){
        return new Promise((resolve,reject) => {
            let pEle = document.createElement('p');
            pEle.innerHTML = this.data[i];
            this.con.appendChild(pEle);
            console.log(this.scroll.scrollToElement);
            this.scroll.scrollToElement(pEle,500);
            setTimeout(() => {
                resolve(true);
            },1000)
        })
    }
}
new Ani({
    data:poem
})